#pragma once

#include <algorithm>
#include "opencv2/myopencv.hpp"

using namespace std;

class SimpleHistogram
{
public:
	int *bins;
	int binNum;
	double binW;
	double ranges[2];
	CvMat *colors;
	double *eachBinRg;
	pair<int, double> *pairs;

private:
	template<typename T> void calcHistFast(CvMat *mat);

public:
	SimpleHistogram(void);
	~SimpleHistogram(void);
	void setRange(double a, double b);
	void setBinNum(int n);
	void sortBins(void);
	void accumulate(void);
	void threshHist(double atLeast);
	void createColor(void);
	void show(char *winName=NULL, int binW=20, int firstN = -1);
	double mainMean(double perc);
	void derive(void);
	void calcHistFast(CvMat *mat, short s);
	cv::Mat backmapColor(cv::Mat mat, short s);
};

